// 引入此文件需自建如下内容：
import { PLAN_TYPE } from '@/constants';

export default {
  props: {
    echartData: {
      type: Array,
      default: () => [],
    },
    formParams: {
      type: Object,
      default: () => ({}),
    },
    includeLeads: {
      type: Boolean,
      default: true
    }
  },
  data() {
    this.PLAN_TYPE = PLAN_TYPE;
    return {
      disabled: false,
      type: '',
    };
  },
  computed: {
    stageName() {
      return this.$store.state.dictionary.dict['business_stage_process_node'] || {};
    },
    stateOptions() {
      return this.$store.state.dictionary.dict['leads_status'] || {};
    },
    businessStateOptions() {
      return this.$store.state.dictionary.dict['business_status'] || {};
    },
    orgOptions() {
      return this.$store.getters.getOrg({
        code: 'ltcsmsizebu',
      });
    },
    nodeOptions() {
      return (
        this.$store.state.dictionary.dict['business_stage_process_node'] || {}
      );
    },
    bisinessTransferOptions() {
      return (
        this.$store.state.dictionary.dict['business_transfer_status'] || {}
      );
    },
    transferOption() {
      return this.$store.state.dictionary.dict['leads_transfer_status'] || {};
    },
    businessOption() {
      return this.$store.state.dictionary.dict['leads_trans_biz_status'] || {};
    },
    columns() {
      return this.type === '线索' ? this.clueColumns : this.businessColumns;
    },
    businessColumns() {
      const columns = [
        {
          align: 'center',
          title: '序号',
          width: 60,
          customRender(t, r, index) {
            return parseInt(index) + 1;
          },
        },
        // {
        //   align: 'center',
        //   title: '商机编号',
        //   dataIndex: 'opportunityNo',
        //   width: 150,
        //   sorter: true,
        //   scopedSlots: { customRender: 'serialNumber' },
        // },
        {
          align: 'center',
          title: '商机名称',
          dataIndex: 'opportunityName',
          width: 160,
          ellipsis: true,
          // sorter: true,
        },
        {
          align: 'center',
          title: '客户简称',
          dataIndex: 'customerShortName',
          width: 160,
          ellipsis: true,
          // sorter: true,
        },
        {
          align: 'center',
          title: '商机状态',
          dataIndex: 'state',
          customRender: text => this.businessStateOptions[text],
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '转派审批状态',
          dataIndex: 'transferStatus',
          width: 160,
          // sorter: true,
          ellipsis: true,
          customRender: text => this.bisinessTransferOptions[text],
        },
        {
          align: 'center',
          title: '商机阶段',
          dataIndex: 'stage',
          customRender: text => this.nodeOptions[text],
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '当前处理人',
          dataIndex: 'handleUserName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '销售组织',
          dataIndex: 'salesOrgCode',
          width: 100,
          // sorter: true,
          ellipsis: true,
          customRender: text => this.orgOptions[text],
        },
        {
          align: 'center',
          title: '销售',
          dataIndex: 'salesName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: 'PM',
          dataIndex: 'pmName',
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '创建人',
          dataIndex: 'createUserName',
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '创建时间',
          dataIndex: 'createTime',
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '最后修改人',
          dataIndex: 'updateUserName',
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '最后修改时间',
          dataIndex: 'updateTime',
          width: 160,
          // sorter: true,
          ellipsis: true,
        },
      ];
      return columns;
    },
    clueColumns() {
      const columns = [
        {
          align: 'center',
          title: '序号',
          width: 60,
          customRender(t, r, index) {
            return parseInt(index) + 1;
          },
        },
        // {
        //   align: 'center',
        //   title: '线索编号',
        //   dataIndex: 'leadsNo',
        //   width: 150,
        //   // sorter: true,
        //   scopedSlots: { customRender: 'clueNumber' },
        // },
        {
          align: 'center',
          title: '线索名称',
          dataIndex: 'leadsName',
          width: 200,
          ellipsis: true,
          // sorter: true,
        },
        {
          align: 'center',
          title: '客户简称',
          dataIndex: 'customerShortName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '线索状态',
          dataIndex: 'leadsStatus',
          width: 100,
          // sorter: true,
          ellipsis: true,
          customRender: text => this.stateOptions[text],
        },
        {
          align: 'center',
          title: '转派状态',
          dataIndex: 'transferStatus',
          width: 100,
          // sorter: true,
          ellipsis: true,
          customRender: text => this.transferOption[text],
        },
        {
          align: 'center',
          title: '转商机审批状态',
          dataIndex: 'businessAuditStatus',
          width: 100,
          // sorter: true,
          ellipsis: true,
          customRender: text => this.businessOption[text],
        },
        {
          align: 'center',
          title: '销售组织',
          dataIndex: 'salesOrgCode',
          width: 100,
          // sorter: true,
          ellipsis: true,
          customRender: text => this.orgOptions[text],
        },
        {
          align: 'center',
          title: '销售',
          dataIndex: 'salesName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: 'PM',
          dataIndex: 'pmName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '创建人',
          dataIndex: 'createUserName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '创建时间',
          dataIndex: 'createTime',
          width: 200,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '最后修改人',
          dataIndex: 'updateUserName',
          width: 100,
          // sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '最后修改时间',
          dataIndex: 'updateTime',
          width: 200,
          // sorter: true,
          ellipsis: true,
        },
      ];
      return columns;
    },
  },
  watch: {
  },
  methods: {

  },
};
